﻿function MasterData() {
    var self = this;
    self.categoryItemclick = function (item) {
        var selected = item.ownerGrid.getSelectionModel().getSelection();
        if (selected.length === 0) {
            return "";
        }

        var store = Ext.getCmp("DataPanel").down("grid").getStore();
        if (!(store.proxy.extraParams)) {
            store.proxy.extraParams = {}
        }
        store.proxy.extraParams["Category"] = selected[0].data.Code;
        store.reload();

        Ext.getCmp("DataPanel").down("hidden[name='Category']").setValue(selected[0].data.Code);
        return true;
    }
    self.getCategoryValue = function (item) {

        var grid = Ext.getCmp("treeCategory").down("grid");
        
        var selected = grid.getSelectionModel().getSelection();
        if (selected.length === 0) {
            return "";
        }
        return selected[0].data.Code;
    }
}